package com.qn.service.impl;

import com.qn.dao.CompanydataDao;
import com.qn.entity.*;
import com.qn.service.CompanyDataService;
import com.qn.utils.MyPageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;

/**
 * (Companydata)表服务实现类
 *
 * @author ph
 * @since 2021-05-06 19:28:53
 */
@Service
@Slf4j
public class CompanyDataServiceImpl implements CompanyDataService {

    @Resource
    private CompanydataDao companydataDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Companydata queryById(Integer id) {
        return this.companydataDao.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param companydata 实例对象
     * @return 实例对象
     */
    @Override
    public void insert(List<CompanyDataVo> companydata) {
        this.companydataDao.insert(companydata);
    }

    /**
     * 修改数据
     *
     * @param companydata 实例对象
     * @return 实例对象
     */
    @Override
    public Companydata update(Companydata companydata) {
        this.companydataDao.update(companydata);
        return this.queryById(companydata.getId());
    }

    @Override
    public int update2(String email) {
        return companydataDao.update2(email);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.companydataDao.deleteById(id) > 0;
    }

    /**
     * 通过条件查询分页
     *
     * @param myPageInfo 查询条件
     * @return 对象列表
     */
    @Override
    public List<Companydata> findByPCIdLimit(MyPageInfo myPageInfo) {
        return this.companydataDao.findByPCIdLimit(myPageInfo);
    }

    /**
     * 通过ID获取email
     *
     * @param id 数组ID
     * @return email
     */
    @Override
    public String findByIdsEmail(Integer id) {
        return this.companydataDao.findByIdsEmail(id);
    }

    /**
     * 查询所有email
     *
     * @param myPageInfo
     */
    @Override
    public List<String> findAllEmail(MyPageInfo myPageInfo) {
        return this.companydataDao.findAllEmail(myPageInfo);
    }

    @Override
    public Integer deleteThisInfo(Integer id) {
        return this.companydataDao.deleteThisInfo(id);
    }

    @Override
    public Qxbcookie getCookie() {
        return companydataDao.getCookie();
    }

    @Override
    public Integer filterRepeat() {
        return companydataDao.filterRepeat();
    }
}
